{*
SPDX-FileCopyrightText: © 2021 Olivier Meunier <olivier@neokraft.net>

SPDX-License-Identifier: AGPL-3.0-only
*}
{{ extends "/_layouts/sidemenu" }}

{{- block sideMenu() -}}
{{- yield sideMenuTitle() content -}}Bookmarks{{- end }}

<form class="mt-2 ml-0.5 mr-1 flex" action="{{ urlFor(`/bookmarks`) }}" method="get">
  <input type="hidden" name="bf" value="1" />
  <div class="flex p-1 form-input rounded-full w-full">
    <input title="search in bookmarks" size="14" type="text" name="search" placeholder="search"
     class="leading-tight w-full rounded-full px-4 py-2 bg-gray-light focus-visible:bg-gray-light text-gray-dark ring-0 ring-offset-0"
    />
    <button title="search"
     class="btn-primary rounded-full w-[2.8rem]"
    >{{ yield icon(name="o-search") }}</button>
  </div>
</form>

<menu class="my-4">
  {{ yield sideMenuItem(name="All", path="/bookmarks", icon="o-library",
                        current=pathIs("/bookmarks")) }}
  {{ yield sideMenuItem(name="Unread", path="/bookmarks/unread", icon="o-check-off",
                        current=pathIs("/bookmarks/unread")) }}
  {{ yield sideMenuItem(name="Archive", path="/bookmarks/archives", icon="o-archive-off",
                        current=pathIs("/bookmarks/archives")) }}
  {{ yield sideMenuItem(name="Favorites", path="/bookmarks/favorites", icon="o-favorite-off",
                        current=pathIs("/bookmarks/favorites")) }}
</menu>

{{- if isset(.Count) }}
  <menu class="my-4">
    {{- if isset(.Count.ByType.article) && .Count.ByType.article > 0 }}
      {{ yield sideMenuItem(name="Articles", path="/bookmarks/articles", icon="o-file",
                            current=pathIs("/bookmarks/articles")) }}
    {{- end -}}

    {{- if isset(.Count.ByType.video) && .Count.ByType.video > 0 }}
      {{ yield sideMenuItem(name="Videos", path="/bookmarks/videos", icon="o-video",
                            current=pathIs("/bookmarks/videos")) }}
    {{- end -}}

    {{- if isset(.Count.ByType.photo) && .Count.ByType.photo > 0 }}
      {{ yield sideMenuItem(name="Pictures", path="/bookmarks/pictures", icon="o-photo",
                            current=pathIs("/bookmarks/pictures")) }}
    {{- end -}}
  </menu>
{{ end -}}

<hr class="w-[25%] border-gray-200 mx-auto">

<menu class="mt-4">
  {{ yield sideMenuItem(name="Labels", path="/bookmarks/labels", icon="o-label",
                        current=pathIs("/bookmarks/labels", "/bookmarks/labels/*")) }}
  {{ yield sideMenuItem(name="Highlights", path="/bookmarks/highlights", icon="o-highlight",
                        current=pathIs("/bookmarks/highlights")) }}
  {{ yield sideMenuItem(name="Collections", path="/bookmarks/collections", icon="o-collection",
                        current=pathIs("/bookmarks/collections", "/bookmarks/collections/*")) }}
</menu>
{{- end -}}
